package com.haixin.test.serviceImpl;

import com.github.pagehelper.PageHelper;
import com.haixin.test.entity.User;
import com.haixin.test.mapper.UserMapper;
import com.haixin.test.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * 请修改注释
 *
 * @author zhangjianshe
 * @date 2021.07.18
 */
@Service
public class UserServiceImpl implements UserService {
    @Autowired
    private UserMapper userMapper;

    @Override
    public User getUserById(long userId) {
        return userMapper.selectByPrimaryKey(userId);
    }

    @Override
    public List<User> listUser(int page, int pageSize) {
        List<User> result = new ArrayList<>();
        try{
            PageHelper.startPage(page,pageSize);
            PageHelper.orderBy("id ASC");
            result = userMapper.selectUser();
        }catch (Exception e){
            e.printStackTrace();
        }
        return result;
    }
}
